


#ifndef PF_VARIABLE_H
#define PF_VARIABLE_H


#include "lx_define.h"
#include "pf_vector.h"
#include "lx_Export.h"

/**
 * A variable of type int, double, string or vector.
 * The variable also contains its type and an int code
 * which can identify its contents in any way.
 *

 */
class LX_EXPORT PF_Variable {
public:
	typedef struct {
                QString s;
		int i;
		double d;
		PF_Vector v;
	} PF_VariableContents;
	
    PF_Variable() {
		type = LX_Define::VariableVoid;
		code = 0;
	}
    PF_Variable(const PF_Vector& v, int c) {
		setVector(v);
		code = c;
	}
    PF_Variable(const QString& v, int c) {
		setString(v);
		code = c;
	}
    PF_Variable(int v, int c) {
		setInt(v);
		code = c;
	}
    PF_Variable(double v, int c) {
		setDouble(v);
		code = c;
	}
    virtual ~PF_Variable() {}

        void setString(const QString& str) {
		contents.s = str;
		type = LX_Define::VariableString;
	}
	void setInt(int i) {
		contents.i = i;
		type = LX_Define::VariableInt;
	}
	void setDouble(double d) {
		contents.d = d;
		type = LX_Define::VariableDouble;
	}
	void setVector(const PF_Vector& v) {
		contents.v = v;
		type = LX_Define::VariableVector;
	}

        QString getString() {
		return contents.s;
	}
	int getInt() {
		return contents.i;
	}
	double getDouble() {
		return contents.d;
	}
	PF_Vector getVector() {
		return contents.v;
	}

	LX_Define::VariableType getType() {
		return type;
	}
	int getCode() {
		return code;
	}

    //friend std::ostream& operator << (std::ostream& os, PF_Variable& v);

private:
	PF_VariableContents contents;
	LX_Define::VariableType type;
	int code;
};

#endif
